Class Utilities

java.lang.Object
ddejonge.bandana.tools.Utilities

public class Utilities
extends java.lang.Object
  • Constructor Summary

    Constructors 
    Constructor Description
    Utilities()  
  • Method Summary

    Modifier and Type Method Description
    static java.util.ArrayList<es.csic.iiia.fabregues.dip.orders.Order> addHoldOrders​(es.csic.iiia.fabregues.dip.board.Power power, java.util.List<es.csic.iiia.fabregues.dip.orders.Order> orders)
    Adds a hold order for each unit of the given power that does not have an order in the given list of orders.
    static java.lang.String padLeft​(java.lang.String string, int requiredLength, char pad)
    Pads the given string on the left with the given char until it reaches the required length.
    static java.lang.String round​(double number, int numDigitsAfterDecimalPoint)
    Returns a String representing the given number, rounded off to the specified number of decimals.
    static java.lang.String testConsistency​(es.csic.iiia.fabregues.dip.board.Game game, java.util.List<BasicDeal> deals)
    Checks whether the given list of deals is consistent.
    Returns null if indeed they are consistent, otherwise returns a string that explains the inconsistency.
    The returned string may be useful for debugging.
    static java.lang.String testValidity​(es.csic.iiia.fabregues.dip.board.Game game, BasicDeal deal)
    Tests whether the OrderCommitments in the deal are possible to execute.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • testConsistency

      public static java.lang.String testConsistency​(es.csic.iiia.fabregues.dip.board.Game game, java.util.List<BasicDeal> deals)
      Checks whether the given list of deals is consistent.
      Returns null if indeed they are consistent, otherwise returns a string that explains the inconsistency.
      The returned string may be useful for debugging.
      Parameters:
      deals -
      Returns:
    • testValidity

      public static java.lang.String testValidity​(es.csic.iiia.fabregues.dip.board.Game game, BasicDeal deal)
      Tests whether the OrderCommitments in the deal are possible to execute. This method returns false if there is any OrderCommitment for which the power does not have a unit at the given location.
      e.g. There is an order for France to move an army from PIC to PAR, but FRA currently does not have an army at PIC.
      Parameters:
      game -
      deal -
      Returns:
    • addHoldOrders

      public static java.util.ArrayList<es.csic.iiia.fabregues.dip.orders.Order> addHoldOrders​(es.csic.iiia.fabregues.dip.board.Power power, java.util.List<es.csic.iiia.fabregues.dip.orders.Order> orders)
      Adds a hold order for each unit of the given power that does not have an order in the given list of orders.
      Parameters:
      game -
      power -
      orders -
      Returns:
    • round

      public static java.lang.String round​(double number, int numDigitsAfterDecimalPoint)
      Returns a String representing the given number, rounded off to the specified number of decimals. e.g, if number == 3.14159265 and numDigits == 3, then this method returns the string "3.141"
      Parameters:
      number -
      numDigits -
      Returns:
    • padLeft

      public static java.lang.String padLeft​(java.lang.String string, int requiredLength, char pad)
      Pads the given string on the left with the given char until it reaches the required length.
      Parameters:
      string -
      requiredLength -
      pad -
      Returns: